Release 10.1A: OpenEdge Development:
Progress Dynamics Advanced Development
Initializing SmartObjects
You start a SmartObject application in two major steps. Creating the object instance is the first of those steps. This section describes the second step.
Once
createobjectsis done, the window publishesinitializeObject, which cascades down as an event to all its children (and their children if any, recursively) and then initializes the window itself, as shown:
Each type of SmartObject does its own initialization, and then passes control up the stack of super procedures with a
RUNSUPER. Among the major events that happen along the way are described in the sections that follow.The initialization runs
enableObjectunless it is instructed not to, that is, unless theDisableOnInitproperty is set toTRUE, which is not its default. It then runsviewObjectunless instructed not to by setting theHideOnInitproperty, whose default value is alsoFALSE.
enableObjectenables any handles in the SmartObject that are not associated with fields from an SDO (these could be extra developer-defined fill-in fields and so on). It sets theObjectEnabledproperty toYES. It also runs the procedureenable_UIfor AppBuilder-generated objects; this is not something you would write or change yourself. Its counterpart for disabling an object is the event proceduredisableObject, as shown:
The
viewObjectevent procedure is actually run for every type of SmartObject, including nonvisual ones, since the concept of being viewed (which sets theObjectHiddenproperty toFALSE) is used essentially as a synonym for active for SmartObjects. For this reason it is supported for all SmartObjects, along with its counterpart, the procedurehideObject. TheviewObjectprocedure actually views the object’s default frame if it has one, sets theObjectHiddenproperty toNOand publishes thelinkStateevent with a parameter of active to signal to other objects, such as SmartPanels and toolbars, that they are now active (so buttons should be enabled that were disabled when the target object was hidden byhideObject, andlinkStatewas published withinactive), as shown:
The initialization sequence then runs
displayobjectsto display any nondatabase fields that can be defined. Thedisplayobjectsevent procedure displays the values of any fields or other basic objects in a visual SmartObject that are not associated with SDO fields. It is run here during initialization, as shown:
The initialization sequence then runs
enableFields,if appropriate (if there is aTableIO-SourceinSavemode, which allows updates to be entered into the viewer’s fields at any time). Then it runsdataAvailableto see if there is a row in theData-Sourcewaiting to be displayed.The
enableFieldsevent procedure enables those viewer fields or browser columns that are associated with SDO data fields (using theEnabledHandlesproperty), setting theirSENSITIVEattribute toYES. (Editors have theirREAD-ONLYattribute set toNO; they are always leftSENSITIVEto allow them to be scrolled.) TheFieldsEnabledproperty is set toYES, and theenableFieldsevent is published to send it on to any contained SmartObjects.The counterpart to
enableFieldsfor disabling data fields is the event proceduredisableFields, as shown:
The
dataAvailableevent procedure is run each time a new (different) row is positioned to in the SDO query, and when anUpdatecompletes. In the case ofinitializeObject,it is run to catch the case where theData-Sourcemight have been initialized first and has already published the event before the viewer was ready to. For visual SmartObjects it causes the field values for the newly selected row to be displayed.For data objects, such as SDOs, it is passed on to a child SDO in a parent-child (master-detail) relationship when the parent SDO moves to a different row. In this case it causes the child SDO’s query to be re-prepared with the foreign key values from the parent row, and the query to be reopened, as shown:
The
pcRelativeparameter to dataAvailable can have these values:
Different— This value indicates that a different row in the SDO query has been positioned to. Viewers and browsers will display that row, and dependent SDOs will reopen their queries based on the key values from the new row."?"— The Unknown value (?) indicates that it is not known whether or not there is a new row (when called frominitializeObject, for instance).SAME— This value signals that the current row has been updated. A viewer or browser will display the row’s new values, but a dependent query object will not bother to reopen its query just because field values have changed in its parent.RESET— This value causes the procedure to check whether the foreign values for the SDO’sForeignFieldskey values have changed since the last call dodataAvailble. If so, then a dependent SDO reopens its query accordingly. If not, it does nothing. This parameter value in effect combines the behavior of theSAMEandDIFFERENTvalues, checking intelligently to see which is the case. It is therefore the most efficient value to pass when it is not always known if a new record with a new set of key values is present.FIRST,NEXT,PREV,LAST— These values signal repositions within a SmartDataBrowser to coordinate with an associated SmartPanel.The
openQueryfunction opens the database query and populates the SDO’sRowObjecttemp-table with the first batch of rows from the database. First it runs thecloseQueryfunction if the query has previously been opened. Then it runs theprepareQueryfunction to re-prepare the query if theQueryStringproperty has been set (described in a later section). If the SDO is divided between client and AppServer, the client side invokesopenQueryon the server to open the actual database query.It then runs the
fetchFirstprocedure to populate the temp-table and position to the first row.fetchFirstruns thesendRowsprocedure, which has both a client and server version, to request the first batch of rows.Finally,
fetchFirston the client side sets theQueryPositionproperty toFIRSTand then publishes thedataAvailableevent with an argument ofFIRSTto cause client-side objects to display the first row, as shown:
The
closeQueryfunction closes both the (client-side)RowObjecttemp-table query, emptying the temp-table, and also the (server-side) database query. It publishesdataAvailableto cause anyData-Targets to erase the current record display (or to close a dependent query if there is one). Your code does not normally callcloseQuerydirectly.The
prepareQueryfunction prepares a new query if it has been modified by the functions used to change the where clause. It is intended to be run only internally on the server. Developers should use the functions described in the section on customizing queries, which in turn invoke this function at the proper time.The
fetchFirstprocedure, along withfetchNext,fetchPrev, andfetchLast, repositions theRowObjectquery to the corresponding row. These procedures also request a new batch of rows from the database, if needed. They reset theQueryPositionproperty to the appropriate value (‘FirstRecord’, ‘LastRecord’, ‘OnlyRecord’, or ‘NotFirstOrLast’), and publishdataAvailableto alert other objects that there is a different row to display or open a dependent query with. As described,fetchFirstis run fromopenQuery.Otherwise, the four procedures are normally published from a
Navigationtoolbar band when the corresponding navigation button is as shown:
The
sendRowsprocedure (along with its two subproceduresclientSendRowsandserverSendRows) transfers batches of rows from server to client. Your code should not normally run this directly.The
dataAvailableprocedure in a data display (Datavis) object such as a viewer or browser runsdisplayFields, which takes as its input parameter a list of values in the form returned by thecolValuesfunction, and moves them into the screen values of the viewer or browser. ThedisplayFieldsprocedure also runsdisplayobjectsto display any nondata-related fields, as shown:
|
Copyright © 2005 Progress Software Corporation www.progress.com Voice: (781) 280-4000 Fax: (781) 280-4095 |